//
//  BaseVM.m
//  YuDou
//
//  Created by qiupeng on 2018/6/24.
//  Copyright © 2018年 yingqi. All rights reserved.
//

#import "BaseVM.h"
#import "AnchorGroup.h"
#import "AnchorModel.h"

@implementation BaseVM

+ (void)loadAnchorDataWithUrl:(NSString *)urlString parameters:(NSDictionary *)parameters success:(HttpSuccessBlock)success
{
    [[HttpTool sharedHttpTool] getWithUrl:urlString parameters:parameters success:^(id JSON) {
       
        success(JSON);
        
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

+ (void)loadAnchorData:(NSString *)urlString parameters:(NSDictionary *)parameters success:(HttpSuccessBlock)success
{
    [self loadAnchorDataWithUrl:urlString parameters:parameters success:^(id JSON) {
        
        NSArray *array = [AnchorGroup mj_objectArrayWithKeyValuesArray:JSON[@"data"]];
        NSMutableArray *temp = [NSMutableArray array];
        
        for (AnchorGroup *ag in array) {
            ag.icon_name = @"home_header_normal";
            NSArray *room_list2 = [AnchorModel mj_objectArrayWithKeyValuesArray:ag.room_list];
            ag.anchors = room_list2;
            [temp addObject:ag];
        }
        success([temp copy]);
    }];
}
@end
